<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	VisitorForm form = (VisitorForm)request.getAttribute("command");
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	String staffid = user.getUsername();
	String dept = request.getAttribute("dept")+"";
	TblRegVisitor visitor = null;
	if(null!=request.getAttribute("visitor")){
		visitor = (TblRegVisitor)request.getAttribute("visitor");
	}
	String dapa = visitor.getDepa();
	String appointtime = (null!=visitor.getAppointtime())?DateFormatUtils.format(visitor.getAppointtime().getTime(), "yyyy-MM-dd HH:mm:ss"):"";
	
%>

<div>
	<div style="display: none">SomeRandomString</div>
	<form id="appointAddForm" target="_coreIframe" method="post" action="<%=request.getContextPath()%>/visitor/doEditAppoint" enctype="multipart/form-data">
		<input type="hidden" name="vid" value="<%=visitor.getVid() %>">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>预约访客记录修改</li>
			</ul>
		</div>
		<table class="formTable">			
			<tr>
				<td class="tdTitle">预约访客：</td>
				<td>
					<input class="inputText xs" type="text" placeholder="必填项" value="<%=visitor.getVname() %>" name="vname">
					<span class="errorTipWrap" id="errorTip_vname"></span>
				</td>
				
			</tr>
			<tr>
				<td class="tdTitle">预约时间：</td>
				<td>
					<input class="inputText xs" type="text" value="<%=appointtime %>" name="appointtime" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 08:00:00'})">
					<span class="errorTipWrap" id="errorTip_appointtime"></span>
				</td>
				
			</tr>
			<tr>
				<td class="tdTitle">证件类型：</td>
				<td>
					<select id="certtype" class="easyui-combobox" name="certtype" style="width:200px;height: 24px;">
						<option value="<%=visitor.getCerttype() %>">
						<%if(visitor.getCerttype().equals("0")){
       					 			String type = "身份证";%>
       					 			<%=type %>
       					 		<%}else if(visitor.getCerttype().equals("1")){
       					 			String type = "其它";%>
       					 			<%=type %>
       					 		<%}else{
       					 			String type = "";%>
       					 			<%=type %>
       					 		<%}%></option>
						<%	if(visitor.getCerttype().equals("0")){%>
							<option value="1">其它</option>
						<%	}else{%>
							<option value="0">身份证</option>
						<%	}%>
					</select>
				<span class="errorTipWrap" id="errorTip_certtype"></span>
				</td>
			</tr>
			
			<tr>
				<td class="tdTitle">证件号码：</td>
				<td>
					<input class="inputText xs" type="text" placeholder="证件号码与联系电话必填其一" value="<%=(null!=visitor.getCert())?visitor.getCert()+"":"" %>" name="cert">
				<span class="errorTipWrap" id="errorTip_cert"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">访客单位：</td>
				<td>
					<input class="inputText xs" type="text"  value="<%=(null!=visitor.getUnits())?visitor.getUnits()+"":"" %>" name="units">
				<span class="errorTipWrap" id="errorTip_units"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">访客人数：</td>
				<td>
					
					
					<input class="inputText xs" type="text" style="width:20px" value="1" name="peoplenum" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
				</td>
			</tr>
			<tr>
				<td class="tdTitle">联系电话：</td>
				<td>
					<input class="inputText xs" type="text" placeholder="证件号码与联系电话必填其一" value="<%=(null!=visitor.getPhone())?visitor.getPhone()+"":"" %>" name="phone" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
				<span class="errorTipWrap" id="errorTip_phone"></span>
				</td>
			</tr>			
			<tr>
				<td class="tdTitle">被访人：</td>
				<td>
					<input class="inputText xs" type="text"  value="<%=(null!=visitor.getByvisitor())?visitor.getByvisitor()+"":"" %>" name="byvisitor">
				<span class="errorTipWrap" id="errorTip_byvisitor"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">被访部门：</td>
				<td>
					<select id="depa" class="easyui-combobox" name="depa" style="width:200px;height: 24px;">
						<option value="<%=(null!=visitor.getDepa())?visitor.getDepa()+"":"" %>"><%=(null!=visitor.getDepa())?visitor.getDepa()+"":"" %></option>
					</select>
				<span class="errorTipWrap" id="errorTip_depa"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">事由：</td>
				<td>
					<select id="aim" class="easyui-combobox" name="aim" style="width:200px;height: 24px;">
						<option value="<%=visitor.getAim() %>"><%=visitor.getAim() %></option>
						<%	if(visitor.getAim().equals("业务洽谈")){%>
								<option value="应聘">应聘</option>
								<option value="访友">访友</option>
								<option value="安装与维修">安装与维修</option>
								<option value="参观">参观</option>
						<%	}else if(visitor.getAim().equals("应聘")){%>
								<option value="业务洽谈">业务洽谈</option>
								<option value="访友">访友</option>
								<option value="安装与维修">安装与维修</option>
								<option value="参观">参观</option>
						<%	}else if(visitor.getAim().equals("访友")){%>
								<option value="业务洽谈">业务洽谈</option>
								<option value="应聘">应聘</option>
								<option value="安装与维修">安装与维修</option>
								<option value="参观">参观</option>
						<%	}else if(visitor.getAim().equals("安装与维修")){%>
								<option value="业务洽谈">业务洽谈</option>
								<option value="应聘">应聘</option>
								<option value="访友">访友</option>
								<option value="参观">参观</option>
						<%	}else{%>
								<option value="业务洽谈">业务洽谈</option>
								<option value="应聘">应聘</option>
								<option value="访友">访友</option>
								<option value="安装与维修">安装与维修</option>
						<%	}%>
					</select>
				<span class="errorTipWrap" id="errorTip_aim"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">备注：</td>
				<td>
					<input class="inputText xs" type="text"  value="<%=(null!=visitor.getRemark())?visitor.getRemark()+"":"" %>" name="remark">
				<span class="errorTipWrap" id="errorTip_remark"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a class="a-btn-microsoft" href="javascript:XF.Visitor.listMyAppoint(<%=user.getEmployId()+"" %>)">取消</a>
					</div>
				</td>
			</tr>	
		</table>
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script type="text/javascript">
	var depa = <%=dept %>;
	$(document).ready(function(){
		var dept = $('#depa').val();
		for(var i=0;i<depa.length;i++){
			if(dept != depa[i].dept){
				$('#depa').append("<option value="+depa[i].dept+">"+depa[i].dept+"</option>");	
			}								    		    		
		}
	});
	
	var staffid = <%=staffid%>
	$(document).ready(XF.Visitor.bigAutocomp(staffid))
</script>



